home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / vidhandl / mico.cpp < prev    next >
C/C++ Source or Header  |  1999-02-03  |  2KB  |  66 lines

  1. /* MICO - SIMPLE PROGRAM THAT FILLS THE SCREEN WITH A CHARACTER   */
  2. /*        AND A COLOR                                             */
  3. /*   ALSO AN EXAMPLE OF VIDEO HANDLING FUNCTIONS                  */
  4.  
  5. //Usage: MICO <input character> <input color>
  6. // Both character and color must be entered in hexadecimal notation.
  7.  
  8. #include <crt.h>
  9. #include <ctype.h>
  10. #include <stdio.h>
  11.  
  12. #define CGA  1
  13. #define MCGA 2
  14. #define EGA  3
  15. #define VGA  9
  16.  
  17. #define VIDEO_ADAPTER VGA
  18.     //replace VIDEO_ADAPTER value if your video adapter is not VGA/SVGA+
  19.  
  20. #include "hextoi.c"
  21.   //hextoi defined in HEXTOI.CPP converts a string (in hexadecimal notation) to a integer
  22.  
  23. //pause pauses the screen
  24.  
  25. #define pause()\
  26. asm mov ah,8;\
  27. asm int 0x21
  28.  
  29. void main (int n, char *ptr[])
  30.  {
  31.     int color,chr;
  32.     if (n<3) //displays help if missing input parameters
  33.      {
  34.         fputs ("\n\
  35. MICO ver 1.0 - Utility that fills the screen with a given character and color\n\
  36. and after pauses until user hits a key\n\n\
  37. \tUsage: MICO <char> <color>\n\n\
  38. \t<char> is the character ASCII code (must be in hexadecimal notation)\n\
  39. \t<color> is the fill color/attribute (must be in hexadecimal notation)\n\n\
  40. by Márcio Afonso Arimura Fialho\n\
  41. Freeware",stdout);
  42.         return;
  43.      }
  44.  
  45.   //converts input parameters to chr and color
  46.     if(hextoi(&chr,ptr[1]) || hextoi(&color,ptr[2]))
  47.      {
  48.       //if input parameters are incorrect
  49.         fputs ("\nIncorrect input. Type MICO with no parameters to get help",stdout);
  50.         return;
  51.      }
  52.  
  53.   //detects number of rows and columns in current video mode
  54.     crt_detect(VIDEO_ADAPTER);
  55.  
  56.   //fills the screen with character given by chr and color color
  57.     fillscr(chr,color);
  58.  
  59.   //pauses
  60.     pause();
  61.  }
  62.  
  63. // By Marcio Afonso Arimura Fialho
  64. // http://pessoal.iconet.com.br/jlfialho
  65. // e-mail: jlfialho@iconet.com.br or (alternate) jlfialho@yahoo.com
  66.